package com.fingard.dsp.bankset;

import java.util.Date;

import com.fingard.constant.Format;
import com.fingard.text.StringHelper;

public class BankFrontStatus {
	public EnBfStatus status;
    public String statusInfo;
    public Date statusTime;
    
    public BankFrontStatus(){
    	status = EnBfStatus.init;
    }
    
    /**用于检测前置机是否有效的查询报文模板*/
    public String cmdPckForCheck;
    
    public String getAtsPckForCheck(){
    	if(StringHelper.hasAnyChar(cmdPckForCheck)){
    		/*    <TransSeqID>20170906231044908</TransSeqID>
    <TransTime>2017-09-06 23:10:44</TransTime>*/
    		String atsPck = cmdPckForCheck;
    		Date timeNow = new Date();
    		int index1 = atsPck.indexOf("<TransSeqID>");
    		int index2 = atsPck.indexOf("</TransSeqID>");
    		if(index1 > 0 && index2 > index1){
    			String transid = Format.DateTime15Year2Format.format(timeNow);
    			int maxLen = index2 - index1 - 12;
    			if(transid.length() > maxLen){
    				transid = transid.substring(transid.length()-maxLen);
    			}
    			atsPck = atsPck.substring(0, index1+12)+transid+atsPck.substring(index2);
    		}
    		index1 = atsPck.indexOf("<TransTime>");
    		index2 = atsPck.indexOf("</TransTime>");
    		if(index1 > 0 && index2 > index1){
    			atsPck = atsPck.substring(0, index1+11)+Format.DateTimeFormat.format(timeNow)+atsPck.substring(index2);
    		}
    		return atsPck;
    	}
    	return null;
    }
}
